﻿@using Dashboard.Models
@using Dashboard.Includes
@using Dashboard.Includes

@model List<List<byte>>
@{ MixedPlotConstants constants = (MixedPlotConstants)ViewBag.constants;}

@{List<int> indexes = new List<int>();
  for (int i = 0; i <= constants.PointsCount; i++)
  {
      indexes.Add(i);
  }
}

<div id="container" style="width: 100%; height: 600px;"></div>

@section Scripts {
    @Scripts.Render("~/bundles/highcharts")

<script>
    var options = {
        chart: {
            type:'spline',
            zoomType: 'x',
            spacingRight: 20,
            renderTo: 'container',

        },
        title: {
            text: 'Mixed @constants.PlotName stat'
        },
        subtitle: {
            text: document.ontouchstart === undefined ?
                'Click and drag in the plot area to zoom in' :
                'Pinch the chart to zoom in'
        },
        xAxis: {
            categories: [@string.Join(", ", indexes)],
            tickInterval: @constants.TickInterval,
            title: {
                text: "@constants.XAxis"
            }
        },
        yAxis: {
            title: {
                text: '%'
            },
            min: 0,
            max: 100
        },
        tooltip: {
            shared: true
        },
        legend: {
            enabled: true,
        },
        plotOptions: {
            spline: {
                marker: {
                    radius: 2,
                    lineColor: '#666666',
                    lineWidth: 1
                }
            }
        },

        series: [
            @{
                List<string> names = ViewBag.namesCounter;

                int count = Model.Count;
    for (int i=0; i<Model.Count; i++ )
    {
        count--;
        @: {type: 'spline',
            @:  pointInterval: @( Math.Round(1.0 / constants.Section, 2).ToString(System.Globalization.NumberFormatInfo.InvariantInfo)),

            @:  name: "@names[i]",
            @:  marker: {enabled: false},
            @:  data: [@string.Join(", ", Model[i])] }
        if (count != 0)
        {
            @: ,
        }

    }
    }

    ]
    };


    $(document).ready(function() {
        chart = new Highcharts.Chart(options);
    });
</script>
}


